var a = getApp();

Page({
  data: {
    show: !0,
    show1: !1,
    // 模拟数据
    managers1: [],
    managerspostArr1Seet: [],
    managerspostArrColorSeet: [],
    currentIndex: 1
  },
  pass(e) {
    var that = this
    var yao_id = e.currentTarget.dataset.yaoid
    var yao_type = e.currentTarget.dataset.yaotype
    var t_id = that.data.t_id
    if (yao_type == 3) {
      wx.showModal({
        content: '是否通过申请',
        success: function(res) {
          if (res.confirm) {
            a.util.request({
              'url': 'entry/wxapp/Yaoqing.pass',
              'data': {
                yao_id: yao_id,
              },
              success: function(res) {
                console.log(res)
                that.getYaoqingyih(t_id)
              }
            })
          }
        }
      })
    }
    if (yao_type == 4) {
      wx.showModal({
        content: '是否踢出成员',
        success: function(res) {
          if (res.confirm) {
            a.util.request({
              'url': 'entry/wxapp/Yaoqing.dellyihu',
              'data': {
                yao_id: yao_id,
              },
              success: function(res) {
                console.log(res)
                that.getYaoqingyih(t_id)
              }
            })
          }
        }
      })
    }
  },
  onLoad: function(options) {
    var that = this

    if (options.yaoqing) {
      that.setData({
        yaoqing: options.yaoqing
      })
    }
    var teampic = options.teampic
    var t_id = options.t_id
    var zid = options.zid
    var teamtext = options.teamtext
    var teamname = options.teamname
    var z_name = options.z_name
    var z_thumbs = options.z_thumbs
    let yaoqinfo = {
      teampic: teampic,
      t_id: t_id,
      zid: zid,
      teamtext: teamtext,
      z_name: z_name,
      teamname: teamname,
      z_thumbs: z_thumbs,
    }
    let arr = JSON.stringify(yaoqinfo);
    that.setData({
      arr: arr,
      t_id: t_id,
      zid: zid
    })
    this.getYaoqingyih(t_id)
  },
  wzclicknavTwo: function(e) {
    console.log(e)
    var that = this
    if (that.data.yaoqing == 1) {
      wx.showToast({
        title: "暂无权限",
        icon: "none",
        duration: 2e3
      });
    } else {
      wx.navigateTo({
        url: "/hyb_yl/backstageTeam/pages/addPerson/addPerson?arr=" + that.data.arr
      })
    }
  },
  onShow: function() {
    var that = this
    var index = that.data.index
    var t_id = that.data.t_id
    if (index == 2) {
      a.util.request({
        'url': 'entry/wxapp/Yaoqing.yaoqingjilu',
        'data': {
          t_id: t_id,
        },
        success: function(res) {
          console.log(res)
          that.setData({
            zhuanjia: res.data,
          })
        }
      })
    } else {
      this.getYaoqingyih(t_id)
    }
    this.setData({
      noFalg: !1
    });
  },
  onlist: function(t) {
    var e = this,
      o = [],
      s = [],
      r = [],
      n = [],
      g = [];
    wx.request({
      url: a.globalData.dic + "doctor/team/member/list/" + e.data.token + "/" + e.data.teamId,
      success: function(a) {
        console.log(a), console.log(a.data.data), e.setData({
          commons: a.data.data.commons,
          managers: a.data.data.managers
        }), console.log(e.data.managers);
        for (t = 0; t < e.data.managers.length; t++) 1 == e.data.managers[t].managerRole ? o.push("团队长") : 2 == e.data.managers[t].managerRole ? o.push("管理员") : 3 == e.data.managers[t].managerRole && o.push("普通团员");
        for (t = 0; t < e.data.managers.length; t++) "1" == e.data.managers[t].jobType ? (s.push("医生"),
          r.push("background-image: linear-gradient(#7dcafe, #6aaeff)")) : "2" == e.data.managers[t].jobType && (s.push("护士"),
          r.push("background-image: linear-gradient(#ff9bb5, #fa7dbf)"));
        for (var t = 0; t < e.data.commons.length; t++) "1" == e.data.commons[t].jobType ? (n.push("医生"),
          g.push("background-image: linear-gradient(#7dcafe, #6aaeff)")) : "2" == e.data.commons[t].jobType && (n.push("护士"),
          g.push("background-image: linear-gradient(#ff9bb5, #fa7dbf)"));
        e.setData({
          managerspostArr: o,
          managerspostArr1: s,
          managerspostArrColor: r,
          commonsArr: n,
          commonsArrArrColor: g
        });
      }
    });
  },
  clicknav: function(e) {
    var that = this
    var zid = e.currentTarget.dataset.zid
    var yao_type = e.currentTarget.dataset.type
    var yao_id = e.currentTarget.dataset.yao_id
    console.log(zid)
    wx.navigateTo({
      url: "/hyb_yl/backstageOther/pages/intro/intro?zid=" + zid + '&arr=' + that.data.arr + '&yao_type=' + yao_type + '&yao_id=' + yao_id
    });
  },
  clicknavTwo: function(a) {
    console.log(a), console.log(a.target.dataset.doctorid);
    var t = String(a.currentTarget.dataset.managerrole);
    wx.setStorageSync("doctorId", a.currentTarget.dataset.doctorid), wx.setStorageSync("managerRole1", t),
      wx.navigateTo({
        url: "/hyb_yl/backstageTeam/pages/doctorIntro/doctorIntro?type=1"
      });
  },
  input: function(t) {
    var e = this,
      o = [],
      s = [],
      r = [];
    console.log(t.detail.value), wx.request({
      url: a.globalData.dic + "doctor/team/member/search",
      data: {
        teamId: e.data.teamId,
        keyWord: t.detail.value
      },
      success: function(a) {
        if (console.log(a.data.data), null == a.data.data) e.setData({
          show: !0,
          show1: !1
        });
        else if (a.data.data.length > 0) {
          e.setData({
            show: !1,
            show1: !0
          }), e.setData({
            managers1: a.data.data
          });
          for (t = 0; t < e.data.managers1.length; t++) 1 == e.data.managers1[t].managerRole ? o.push("团队长") : 2 == e.data.managers1[t].managerRole ? o.push("管理员") : 3 == e.data.managers1[t].managerRole && o.push("团员");
          for (var t = 0; t < e.data.managers1.length; t++) 1 == e.data.managers1[t].jobType ? (s.push("医生"),
            r.push("background-image: linear-gradient(#7dcafe, #6aaeff)")) : 2 == e.data.managers1[t].jobType && (s.push("护士"),
            r.push("background-image: linear-gradient(#ff9bb5, #fa7dbf)"));
          e.setData({
            managerspostArrSeet: o,
            managerspostArr1Seet: s,
            managerspostArrColorSeet: r
          }), console.log(e.data.managers1);
        }
      }
    });
  },
  tap: function(e) {
    var that = this
    var t_id = that.data.t_id
    var index = e.target.dataset.current
    if (index == 2) {
      a.util.request({
        'url': 'entry/wxapp/Yaoqing.yaoqingjilu',
        'data': {
          t_id: t_id,
        },
        success: function(res) {
          console.log(res)
          that.setData({
            zhuanjia: res.data,
            index: 2
          })

        }
      })
    } else {
      this.getYaoqingyih(t_id)
    }
    this.setData({
      currentIndex: e.target.dataset.current,
      noFalg: !1
    });
  },

  lower: function() {
    var t, e = this,
      o = (wx.getStorageSync("log"), e.data.askmanagers),
      s = e.data.currentResult,
      r = e.data.askmanagerspostArr,
      n = e.data.askmanagerspostArr1,
      g = e.data.askmanagerspostArrColor,
      d = e.data.askmanagerspostArrColor1;
    console.log(s);
    var c = this;
  },

  //查询邀请的医护
  getYaoqingyih: function(t_id) {
    var that = this
    a.util.request({
      'url': 'entry/wxapp/Yaoqing.display',
      'data': {
        t_id: t_id,
      },
      success: function(res) {
        console.log(res)
        that.setData({
          zhuanjia: res.data
        })
      }
    })
  }
});